package com.longge;

public class KLengthApart {

    public boolean kLengthApart(int[] nums, int k) {

        int countK = -1;
        for (int num : nums) {
            if (num == 1) {
                if (countK != -1 && countK < k) return false;
                countK = 0;
            } else {
                if (countK !=-1){
                    countK++;
                }
            }
        }
        return true;
    }

    public static void main(String[] args) {
        new KLengthApart().kLengthApart(new int[]{0,1,0,1},1);
    }
}
